<template>
    <div class="template-form-Lu">
        <a-modal
            :title="'干部职工离岗请示登记表' + (linkName == '数据修订'?'（数据修订）':'')"
            :visible="applicationFormVisible"
            :maskClosable="false"
            :closable="true"
            :destroyOnClose="true"
            width="100%"
            :dialog-style="{ margin: '0 auto' }"
            wrapClassName="applicationModal-form-fullmodal-Lu"
            @cancel="closeVisible">
            <div class="applicationModal-div-box-Lu">
                <div class="tabs-card-edit-box">
                    <a-tabs type="card" v-model:activeKey="summaryActiveKey" @change="summaryActiveChange">
                        <a-tab-pane key="申请表" tab="申请表"></a-tab-pane>
                        <a-tab-pane key="流转记录" tab="流转记录"></a-tab-pane>
                    </a-tabs>
                </div>
                <div  class="tab-box-v1">
                    <div v-if="summaryActiveKey == '申请表'" style="width: 70%;margin: 0 auto;padding-top: 30px;padding-bottom: 30px;">
                        <a-spin :spinning="spinning">
                            <a-button class="blue-btn" @click="printClick('离岗',formState,qmImgList)" v-if="linkName == '我的已办'">打印</a-button>
                            <a-form :form="aform" ref="form" class="internalControl-reimbursement-model-form-box">
                                <a-descriptions bordered style="width: 100%;">
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='离岗申请' || linkName == '数据修订'">*</span>
                                            离岗（请假）类型
                                        </span>
                                        <a-form-item ref="flglx" prop="flglx" class="zm-form-model">
                                            <a-radio-group
                                                v-if="linkName=='离岗申请' || linkName == '数据修订'"
                                                v-model:value="formState.flglx"
                                                v-decorator="[
                                                    'flglx', {initialValue:formState.flglx,rules: rules.flglx}]"
                                                >
                                                <a-radio value="因公">
                                                    因公
                                                </a-radio>
                                                <a-radio value="因私">
                                                    因私
                                                </a-radio>
                                            </a-radio-group>
                                            <span v-else>{{ formState.flglx }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='离岗申请' || linkName == '数据修订'">*</span>
                                            离岗时间
                                        </span>
                                        <a-form-item ref="flgsj" prop="flgsj" class="zm-form-model">
                                            <a-date-picker
                                                v-if="linkName=='离岗申请' || linkName == '数据修订'"
                                                show-time
                                                v-model="formState.flgsj"
                                                placeholder="请选择离岗时间"
                                                @change="flgsjChange"
                                            />
                                            <span v-else>{{ moment(formState.flgsj).format('YYYY-MM-DD HH:mm:ss') }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='离岗申请' || linkName == '数据修订'">*</span>
                                            回岗时间
                                        </span>
                                        <a-form-item ref="fhgsj" prop="fhgsj" class="zm-form-model">
                                            <span v-if="formState.fhgsj">{{ formState.fhgsj }}</span>
                                            <span v-else>自动计算，无需填写</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item>
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='离岗申请'">*</span>
                                            共离开
                                        </span>
                                        <a-form-item ref="flksj" prop="flksj" class="zm-form-model">
                                            <div v-if="linkName=='离岗申请' || linkName == '数据修订'">
                                                <a-select
                                                    v-model="formState.flksj"
                                                    default-value="2"
                                                    style="width: 70px"
                                                    @change="handleChange">
                                                    <a-select-option :value="0.5">
                                                        0.5
                                                    </a-select-option>
                                                    <a-select-option :value="1">
                                                        1
                                                    </a-select-option>
                                                    <a-select-option :value="1.5">
                                                        1.5
                                                    </a-select-option>
                                                    <a-select-option :value="2">
                                                        2
                                                    </a-select-option>
                                                </a-select>
                                                    小时
                                            </div>
                                            <span v-else>{{ formState.flksj }} 小时</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="2">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='离岗申请'">*</span>
                                            离岗（请假）理由
                                        </span>
                                        <a-form-item ref="flgsy" prop="flgsy" class="zm-form-model">
                                            <a-textarea
                                                v-if="linkName=='离岗申请' || linkName == '数据修订'"
                                                v-model="formState.flgsy"
                                                placeholder="请输入离岗（请假）理由:"
                                                :auto-size="{ minRows: 2}"
                                                v-decorator="[
                                                    'flgsy', {initialValue:formState.flgsy,rules: rules.flgsy}]"
                                            />
                                            <span v-else>{{ formState.flgsy }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item v-if="formState.flglx == '因公'" :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            附&emsp;&emsp;件
                                        </span>
                                        <a-form-item ref="fnbyj" prop="fnbyj" class="zm-form-model">
                                            <uploadFilesList :config="uploadFilesListConfig" @emitFormid="emitFormid" :filesFormState="{...formState,flgsj:formState.flgsj?moment(formState.flgsj).format('YYYY-MM-DD HH:mm:ss'):null}"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('科室审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('科室审批').hjmc">*</span>
                                            科室负责人意见
                                        </span>
                                        <a-form-item ref="fksfzryj" prop="fksfzryj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('科室审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffksfzryj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('OA离岗',formState.fksfzryj,'fksfzryj')"
                                                    v-decorator="[
                                                        'fksfzryj', { initialValue:formState.fksfzryj, rules: rules.fksfzryj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.fksfzrqmsj)"
                                                        :default-value="moment(formState.fksfzrqmsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'fksfzrqmsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fksfzryj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('科室审批')" :src="getUrl('科室审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fksfzrqm }}</span>
                                                    <span>{{ formState.fksfzrqmsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('分管领导审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('分管领导审批').hjmc">*</span>
                                            分管领导意见
                                        </span>
                                        <a-form-item ref="fksfzryj" prop="fksfzryj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('分管领导审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsRefffgldyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('OA离岗',formState.ffgldyj,'ffgldyj')"
                                                    v-decorator="[
                                                        'ffgldyj', { initialValue:formState.ffgldyj, rules: rules.ffgldyj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.ffgldqmsj)"
                                                        :default-value="moment(formState.ffgldqmsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'ffgldqmsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.ffgldyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('分管领导审批')" :src="getUrl('分管领导审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.ffgldqm }}</span>
                                                    <span>{{ formState.ffgldqmsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('销假').blzt == '已办' && linkName !== '数据修订'">
                                        <span slot="label" class="descriptions-label-slot">
                                            返岗确认
                                        </span>
                                        <a-form-item ref="fksfzryj" prop="fksfzryj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="descriptionsData('销假').blzt == '已办'">
                                                <p>确认销假</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('销假')" :src="getUrl('销假')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fxjr }}</span>
                                                    <span>{{ formState.fxjsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            备注
                                        </span>
                                        <a-form-item class="zm-form-model">
                                            <p style="font-size: 16px;">
                                                1.因公离岗在南宁市范围内参加外单位(科室)委派工作的,须附相关证明材料。
                                                    离岗1日以内(含1日)须由本科室负责人签署意见,报分管领导审批,1日以上须加报中心主任审批;<br/>
                                                2.因私离岗2小时以内(含2小时)须经本科室负责人审核,并报分管领导批准;<br/>
                                                3.请假结束需本人按时到办公室销假;<br/>
                                                </p>
                                        </a-form-item>
                                    </a-descriptions-item>
                                </a-descriptions>
                            </a-form>
                        </a-spin>
                    </div>
                    <div v-if="summaryActiveKey == '流转记录'" style="padding-top: 30px;">
                        <transferRecords
                            ref="transferRecordsRef"
                            :config="circulationDataTableConfig"
                            @getCirculationQmImg="getCirculationQmImg"/>
                    </div>
                </div>
            </div>
            <template slot="footer">
                <div v-if="linkName == '我的已办'">
                    <a-button class="blue-btn" @click="closeVisible">关闭</a-button>
                </div>
                <div v-else-if="linkName == '销假'">
                    <a-button class="blue-btn" @click="onSubmit('提交')">确认销假</a-button>
                </div>
                <div v-else-if="linkName == '数据修订'">
                    <a-button class="blue-btn" @click="updataData">确认修订</a-button>
                </div>
                <div v-else>
                    <a-button @click="onSave('保存')">
                        保存
                    </a-button>
                    <a-button class="blue-btn" @click="onSubmit('提交')">
                        提交
                    </a-button>
                    <a-button v-if="linkName !== '离岗申请'" class="red-btn" @click="returnClick">
                        退回
                    </a-button>
                </div>
            </template>
        </a-modal>
        <printModal ref="printModalRef" />
    </div>
</template>
<script>
import {
    initBzFlow,
    saveFlow,
    submitFlow,
    queryJobByJobId,
    returnUpperzdyFlowJob,
    getMoreUserSignLinkList,
    pidgetlchj,
    editFuntion,
} from './service/index'
import assessCheckApi from './service/api.js'
import transferRecords from '../modal/transferRecords'
import printModal from '../modal/printModal'
import uploadFilesList from '../modal/uploadFilesList'
import moment from 'moment'
export default {
    components: {
        transferRecords,
        printModal,
        uploadFilesList,
    },
    data() {
        return {
            moment:moment,
            applicationFormVisible: false,
            summaryActiveKey: '申请表',
            aform:this.$form.createForm(this, { name: 'aform' }),
            formState: {
                flksj: 2,
            },
            circulationDataTableConfig: {
                api: assessCheckApi.flowJkPage,
                rowId: 'id',
                urlType: true,
                paramet:{
                    oaid: ''
                }
            },
            uploadFilesListConfig: {
                isUpload: false,
                fjAddApi: assessCheckApi.initBzFlow,
            },
            rules:{
                flglx: [{
                    required: true,
                    message: '请选择离岗类型',
                    trigger: 'blur',
                }],
                flgsj: [{
                    type: 'object',
                    required: true,
                    message: '请选择离岗时间',
                    trigger: 'blur',
                }],
                flgsy: [{
                    required: true,
                    message: '请输入离岗（请假）理由',
                    trigger: 'blur',
                }],
                fksfzryj: [
                    { required: true, message: '请输入本科（室）意见', trigger: 'blur' }
                ],
                ffgldyj: [
                    { required: true, message: '请输入中心分管领导意见', trigger: 'blur' }
                ],
            },
            qmImgList: [],
            displayList: [],
            linkName: '离岗申请',
            spinning: false,
        }
    },
    mounted() {
        this.$refs.reviewOpinionsRef= Date.now()
        this.uploadFilesListConfig.isUpload = (this.linkName == '离岗申请' || this.linkName == '数据修订')?true:false
    },
    methods: {
        getInitData(){
            this.summaryActiveKey = '申请表'
            this.formState = {}
            this.formState = {
                flksj: 2,
            }
        },
        getData(val){
            //console.log('已办进来后',val)
            if(val){
                this.summaryActiveKey = '申请表'
                this.linkName = val.hjmc
                this.uploadFilesListConfig.isUpload = (this.linkName == '离岗申请' || this.linkName == '数据修订')?true:false
                this.formState = {}
                this.formState = {
                    ...val.oaMap,
                    jobid: val.jobMap?val.jobMap.id:''
                }
                this.formState.flgsj = val.oaMap.flgsj?moment(val.oaMap.flgsj):null
                this.circulationDataTableConfig.paramet.oaid = this.formState.id
                this.qmImgList = []
                this.displayList = []
                this.getDisplayList()
            }
        },
        getDisplayList(){
            pidgetlchj({pid:this.formState.id}).then((res) => {
                let arr1 = res.result
                this.displayList = []
                this.displayList = res.result

                if(this.linkName == '数据修订'){
                    const index = this.displayList.findIndex((item) => item.blzt == '待办');
                    if (index !== -1) {
                        this.displayList.splice(index, 1);
                    }
                    //console.log('this.displayList',this.displayList)
                }

                arr1.forEach(async item => {
                    if(item.blrid && item.blzt!=='待办'){
                        let resa = await getMoreUserSignLinkList({ids:item.blrid})
                        if(resa.success && resa.result.length){
                            if(resa.result[0].signLink == ''){
                                // //console.log('没有获得图片 signLink == 0')
                                this.qmImgList.push({
                                    hjmc: item.hjmc,
                                    url: null
                                })
                            } else {
                                this.qmImgList.push({
                                    hjmc: item.hjmc,
                                    url: resa.result[0].signLink+'&aa='+Date.now()
                                })
                                // //console.log('获得的签名图片列表',this.qmImgList)
                            }
                        } else {
                            // //console.log('没有获得图片')
                        }
                    } else {}
                })
                // //console.log('最终获得的签名图片列表---',this.qmImgList)
            })
        },
        closeVisible(){
            this.applicationFormVisible = false
            this.$emit('success')
        },
        summaryActiveChange(val){
            //console.log(val)
        },
        // 离岗时间
        flgsjChange(val){
            //console.log(val)
            this.formState.flgsj = val
            if(val == null){
                this.formState.fhgsj = ''
            }
            if(this.formState.flksj !== 0 && val !== null){
                var haomiao = this.formState.flksj * 3600000
                var stime = Date.parse(new Date(this.formState.flgsj));
                var ztime = Number(stime) + Number(haomiao)
                var htime = new Date(ztime)

                this.formState.fhgsj = moment(htime).format('YYYY-MM-DD HH:mm:ss')
            }
        },
        // 选择离岗小时数
        handleChange(value) {
            if(this.formState.flgsj !== ''){
                var haomiao = value * 3600000
                var stime = Date.parse(new Date(this.formState.flgsj));
                var ztime = Number(stime) + Number(haomiao)
                var htime = new Date(ztime)
                // //console.log()

                this.formState.fhgsj = moment(htime).format('YYYY-MM-DD HH:mm:ss')
                //console.log(this.formState.fhgsj)
            }
        },
        emitFormid(val){
            this.formState = {
                jobid:val.jobMap.id,
                ...val.oaMap
            }
            //console.log('formState===',this.formState)
        },
        getCirculationQmImg(item1,item2){
            // //console.log('-----?????-----',item1,item2)
            this.qmImgList = []
            this.displayList = []
            this.qmImgList = item1
            this.displayList = [...item2]
            // //console.log('111111111',this.qmImgList)
            // //console.log('222222222',this.displayList)
        },
        getUrl(hjmcName){
            let url = ''
            // //console.log('没有？？？',this.qmImgList)
            this.qmImgList.forEach(item => {
                // //console.log(hjmcName,item)
                if(item.hjmc == hjmcName){
                    //console.log('该环节有签名图片',hjmcName,item)
                    url = item.url
                }
            })
            //console.log(hjmcName,url)
            return url
        },
        descriptionsData(hjmc){
            let data = {}
            this.displayList.forEach(item => {
                // //console.log('descriptionsData000',hjmc,item)
                if(item.hjmc == hjmc){
                    data = {...item}
                }
            })
            // //console.log('descriptionsData',data)
            return data
        },
        getInputOpinion(val,valueData){
            //console.log(val,valueData)
            let data = this.formState
            data[valueData.hjmc] = val
            this.aform.setFieldsValue({
                fksfzryj: this.formState.fksfzryj,
                fbgspcyj: this.formState.fbgspcyj,
                ffgldyj: this.formState.ffgldyj,
                fdwldspr: this.formState.fdwldspr
            });
        },
        opinions(val1,val2,val3){
            //console.log(val1,val2,val3)
            this.$refs[`reviewOpinionsRef${val3}`].getData({opinionType:val1,oldVal:val2,valueData:{hjmc:val3}})
        },
        onSave(){
            let data = {}
            let sdata = {
                jobid: this.formState.jobid,
                oaid: this.formState.id,
                map: {},
                opinion: '',
            }
            if(this.linkName == '离岗申请'){
                data = {
                    flgsy: this.formState.flgsy,
                    flglx: this.formState.flglx,
                    flgsj: this.formState.flgsj?moment(this.formState.flgsj).format('YYYY-MM-DD HH:mm:ss'):null,
                    fhgsj: this.formState.fhgsj,
                    flksj: this.formState.flksj,
                    id: this.formState.id?this.formState.id:''
                }
                sdata.map = {
                    ...data
                }
                this.formState.id?this.saveFlowFuntion(sdata):this.initBzFlowFuntion(data)
            } else if(this.linkName == '科室审批'){
                sdata.map = {
                    fksfzrqm: this.formState.fksfzrqm,
                    fksfzrqmsj: this.formState.fksfzrqmsj,
                    fksfzryj: this.formState.fksfzryj,
                }
                sdata.opinion = this.formState.fksfzryj,
                this.saveFlowFuntion(sdata)
            } else if(this.linkName == '分管领导审批'){
                sdata.map = {
                    ffgldyj: this.formState.ffgldyj,
                    ffgldqm: this.formState.ffgldqm,
                    ffgldqmsj: this.formState.ffgldqmsj,
                }
                sdata.opinion = this.formState.ffgldyj,
                this.saveFlowFuntion(sdata)
            } else if(this.linkName == '销假'){
                sdata.map = {
                    fdwldspr: this.formState.fdwldspr,
                    fdwldsprqm: this.formState.fdwldsprqm,
                    fdwldsprqmsj: this.formState.fdwldsprqmsj,
                }
                sdata.opinion = this.formState.fdwldspr,
                this.saveFlowFuntion(sdata)
            }
        },
        onSubmit(){
            this.aform.validateFields((err, values) => {
                if (!err) {
                    var that = this
                    that.$confirm({
                        title: '您确定要提交吗?',
                        onOk() {
                            let data = {
                                jobid: that.formState.jobid,
                                oaid: that.formState.id,
                                map: {},
                                opinion: '',
                            }
                            if(that.linkName == '离岗申请'){
                                data.map = {
                                    flgsy: that.formState.flgsy,
                                    flglx: that.formState.flglx,
                                    flgsj: that.formState.flgsj?moment(that.formState.flgsj).format('YYYY-MM-DD HH:mm:ss'):null,
                                    fhgsj: that.formState.fhgsj,
                                    flksj: that.formState.flksj,
                                    id: that.formState.id?that.formState.id:'',
                                    fsffqlc: that.formState.id?'':'是',
                                }
                                that.formState.id?that.submitFlowFuntion(data):that.initBzFlowFuntion(data.map,'1')
                            } else if(that.linkName == '科室审批'){
                                data.map = {
                                    fksfzrqm: that.formState.fksfzrqm,
                                    fksfzrqmsj: that.formState.fksfzrqmsj,
                                    fksfzryj: that.formState.fksfzryj,
                                }
                                data.opinion = that.formState.fksfzryj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '办公室审核'){
                                data.map = {
                                    fbgspcyj: that.formState.fbgspcyj,
                                    fbgspcyjr: that.formState.fbgspcyjr,
                                    fbgspcyjsj: that.formState.fbgspcyjsj
                                }
                                data.opinion = that.formState.fbgspcyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '分管领导审批'){
                                data.map = {
                                    ffgldyj: that.formState.ffgldyj,
                                    ffgldqm: that.formState.ffgldqm,
                                    ffgldqmsj: that.formState.ffgldqmsj,
                                }
                                data.opinion = that.formState.ffgldyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '销假'){
                                data.map = {
                                    fdwldspr: that.formState.fdwldspr,
                                    fdwldsprqm: that.formState.fdwldsprqm,
                                    fdwldsprqmsj: that.formState.fdwldsprqmsj,
                                }
                                data.opinion = that.formState.fdwldspr,
                                that.submitFlowFuntion(data)
                            }
                        },
                        onCancel() {},
                    });
                }
            })
        },
        initBzFlowFuntion(data,type){
            initBzFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.formState = {}
                    this.formState = {
                        ...res.result.oaMap,
                        jobid: res.result.jobMap.id
                    }
                    this.formState.flgsj = this.formState.flgsj?moment(this.formState.flgsj):null
                    if(type){
                        this.closeVisible()
                    }
                } else {
                    this.$message.warning(res.message)
                }
                this.loading = false
            })
        },
        saveFlowFuntion(data){
            this.spinning = true
            saveFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                } else {
                    this.$message.warning(res.message)
                }
                this.spinning = false
            })
        },
        submitFlowFuntion(data){
            this.spinning = true
            submitFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.warning(res.message)
                }
                this.spinning = false
            })
        },
        // 退回
        returnClick(){
            this.aform.validateFields((err, values) => {
                if (!err) {
                    var that = this
                    that.$confirm({
                        title: '您确定要退回吗?',
                        onOk() {
                            that.spinning = true
                            queryJobByJobId({jobid:that.formState.jobid}).then(res => {
                                let list = res.result.jobHistoryList
                                let slist = list.filter(item => item.fhjmc == '离岗申请')
                                const sortedDates = slist.sort((a, b) => new Date(b) - new Date(a));
                                that.returnFuntion(that.formState.jobid,sortedDates[slist.length - 1].id)
                            })
                        },
                        onCancel() {},
                    })
                }
            })
        },
        returnFuntion(jobid,ids){
            let returnStr = ''
            if(this.linkName == '科室审批'){
                returnStr = this.formState.fksfzryj
            } else if(this.linkName == '分管领导审批'){
                returnStr = this.formState.ffgldyj
            }
            let data = {
                jobid: jobid,
                opinion: returnStr,
                shjid: ids,
                lcmbbm: '',
                smgflag: '',
                smsContent: '',
            }
            returnUpperzdyFlowJob(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.error(res.message)
                }
                this.spinning = false
            })
        },
        printClick(type,value,qmValue){
            this.$refs.printModalRef.modalClick(type,value,qmValue)
        },
        yjTimeChange(val,name){
            let data = this.formState
            data[name] = moment(val).format('YYYY-MM-DD HH:mm:ss')
        },
        updataData(){
            var that = this
            that.$confirm({
                title: '您确定修改当前表单数据吗?',
                onOk() {
                    let data = {
                        id: that.formState.id,
                        flgsy: that.formState.flgsy,
                        flglx: that.formState.flglx,
                        flgsj: that.formState.flgsj?moment(that.formState.flgsj).format('YYYY-MM-DD HH:mm:ss'):null,
                        fhgsj: that.formState.fhgsj,
                        flksj: that.formState.flksj,
                        fksfzrqm: that.formState.fksfzrqm,
                        fksfzrqmsj: that.formState.fksfzrqmsj?moment(that.formState.fksfzrqmsj).format('YYYY-MM-DD HH:mm:ss'):null,
                        fksfzryj: that.formState.fksfzryj,
                        ffgldyj: that.formState.ffgldyj,
                        ffgldqm: that.formState.ffgldqm,
                        ffgldqmsj: that.formState.ffgldqmsj?moment(that.formState.ffgldqmsj).format('YYYY-MM-DD HH:mm:ss'):null,
                    }
                    //console.log(data)
                    that.spinning = true
                    editFuntion(data).then(res => {
                        if(res.code == 200){
                            that.$message.success(res.message)
                        } else {
                            that.$message.warning(res.message)
                        }
                        that.spinning = false
                    })
                },
                onCancel() {
                    //console.log('Cancel');
                },
            });
        },
    }
}
</script>
<style>
@import url('../css/oaLess.css');
</style>
